package yang.VirtualMachine.chapter9.classStruct.constantPool;

import java.io.IOException;
import java.io.InputStream;

import yang.VirtualMachine.chapter9.ClassBean;
import yang.VirtualMachine.chapter9.ClassUtil;

/**
 * u1 tag;u2 descriptor_index;
 * @author xinxin
 */
public class Con_NameAndTypeProcesser implements PoolValue {
	
	private int nameIndex;
	
	private int descriptorIndex;

	@Override
	public void process(InputStream input) throws IOException {
		nameIndex = (int) ClassUtil.getNumByStream(input, 2);
		descriptorIndex = (int) ClassUtil.getNumByStream(input, 2);
	}

	@Override
	public String getValue() {
		PoolValue nameValue = ClassBean.getInstance().constantPool[nameIndex];
		PoolValue descValue = ClassBean.getInstance().constantPool[descriptorIndex];
		return descValue.getValue() + ":" + nameValue.getValue();
	}

}
